<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: bobo
  Date: 16-11-1
  Time: 下午4:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <jsp:include page="../layout/head.jsp" >
        <jsp:param name="title" value="留言审批" />
    </jsp:include>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 留言管理</strong></div>
    <table class="table table-hover text-center">
        <tr>
            <th width="120">ID</th>
            <th>姓名</th>
            <th>状态</th>
            <th width="25%">内容</th>
        </tr>
        <c:forEach items="${page.list}" var="message" varStatus="abc">
        <tr>
            <td>${message.id}</td>
            <td>${message.user.name}</td>
            <td>
                禁用<input type="radio" class="${message.id}" name="${message.id}status" value="0" ${message.status ==0 ?"checked":""} onchange="radioValue(this)"><br>
                启用<input type="radio" class="${message.id}" name="${message.id}status" value="1" ${message.status ==1 ?"checked":""} onchange="radioValue(this)"><br>
                屏蔽<input type="radio" class="${message.id}" name="${message.id}status" value="2" ${message.status ==2 ?"checked":""} onchange="radioValue(this)">
            </td>
            <td>${message.content}</td>
            <%--<td>--%>
                <%--<a class="button border-red" href="${pageContext.request.contextPath}/admin/message/del?id=${message.id}"--%>
                   <%--onclick="if(confirm('删除后不可恢复'))return true;return false;">删除</a>--%>
            <%--</td>--%>
        </tr>
        </c:forEach>
        <tr>
            <td colspan="5">
                <jsp:include page="../layout/pager.jsp">
                    <jsp:param name="pageNum" value="${page.pageNum}"/>
                    <jsp:param name="current" value="${page.current}"/>
                    <jsp:param name="pageSize" value="${page.pageSize}"/>
                    <jsp:param name="url" value="${pageContext.request.contextPath}/admin/message/getMessages"/>
                </jsp:include>
            </td>
        </tr>
    </table>
</div>
<script>
    function radioValue(node) {
        $.ajax({
            url: "${pageContext.request.contextPath}/admin/message/changeStatus",
            type: "get",
            data: {"id": node.className, "status": node.value},
            success:function (data) {
                if(data == "true") {
                    alert("修改成功");
                }
            },
            error: function () {
                alert("修改失败");
            }
        })
    }
</script>
</body>
</html>
